auto();


// 给特定QQ用户发送消息,在此之前最好确保QQ已经运行

var qqNumber = "93434692";
var message = "Hello，Are you OK ?";

if (!device.isScreenOn()) {
    // 屏幕关闭则唤醒
    device.wakeUp();
    sleep(2000); // 等待屏幕完全亮起
    console.log("屏幕已唤醒");
} else {
    console.log("屏幕已经是亮的");
}

launchApp("QQ"); // 打开QQ com.tencent.mobileqq
sleep(7000);


app.startActivity({
    action: "android.intent.action.VIEW",
    data: "mqq://im/chat?chat_type=wpa&version=1&src_type=web&uin=" + qqNumber,
    packageName: "com.tencent.mobileqq",
});

// Wait for the interface to load
sleep(3000);

// Send message automatically (if supported by QQ version)
// This part depends on QQ's UI and may need adjustment
var inputBox = className("EditText").findOne(5000);
if (inputBox) {
    inputBox.setText(message);

    // Find and click send button
    var sendButton = text("发送").findOne(3000) || desc("发送").findOne(3000);
    if (sendButton) {
        sendButton.click();
    }
}

 